package cn.yunhe.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class Factory {
	
	static SqlSession session = null;
	static{
		InputStream isInputStream = null;
		try {
			isInputStream = Resources.getResourceAsStream("mybatis.xml");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
		SqlSessionFactory factory =new SqlSessionFactoryBuilder().build(isInputStream);
		session = factory.openSession();
	}
	
	public static SqlSession getSqlSession() {
		return session;
	}
}